define(function(require,exports,module) {
	// require('./plug/hammer.min');
    var myPub = require('./public');

	$(function() {
	    var oShadow = $('.js_shadow');				//阴影
	    var oFooter = $('.js_footer');              //底部
	    var oGoTop = $('.js_goTop');                //回到顶部
	    var oSearchBox = $('.js_searchBox');       	//搜索部分
	    var oSearchTxt = $('.js_searchTxt');        //搜索框
	    var oSearchClear = $('.js_clearBtn');       //搜索框清空
	    var maxLWord = $('.js_wordmax');            //最大字数
	    var oUserMessage = $('.js_message').find('textarea');  //留言区域
	    var oLoadingPage =$('.js_loadingPage');

	    var $window = $(window)
	    var oSideBox = $('.js_sideBox');		//侧边按钮框

	    var oContain = $('.js_contain');
	    var oShadow = $('.js_shadow');

	    //oShadow.hammer().on('tap',function(e) {  myPub.HamstopPropaga(); e.stopPropagation()  })

	   	WindowScroll()
    	$window.on('scroll',function(e) {
    		myPub.throttle(WindowScroll,window);
    	});

	   	oSearchBox.on("touchmove",function(e) {e.preventDefault()});
    	oFooter.on("touchmove",function(e) {e.preventDefault()});
	    oLoadingPage.on('touchmove',function() {return false});
	    oShadow.on("touchmove",function(e) {e.preventDefault()});


        function isSFApp(){
            var isSFApp = 0;
            //安卓识别
            var ua = window.navigator.userAgent;
            // console.log(ua)
            if (ua.indexOf('SFApp') != -1) {
                // console.log("当前为顺丰金融app打开!");
                isSFApp = 1;
            }
            //ios识别
            try{
                if(SFPayNative){
                    // console.log("当前为顺丰金融app打开!");
                    isSFApp = 1;
                }
            }catch (e){
            }
            return isSFApp;
        }
        /**
         隐藏、显示顺丰金融app导航栏js函数
         state=0表示隐藏，1 表示显示
         */
        function showNavigation(state){
            if(state==1){
                $('body').append('<div  class="sideBox " style="right: 0; bottom: 5rem; "><a href="javascript:history.back();" class="goIcon" style="display: block; font-size: 1rem;"><span class="icon-chevron-left" ></span><span>返回</span></a></div>');
            }
        }

        showNavigation(isSFApp());



	    // 回到顶部
	    oGoTop.hammer().on('tap',function(e) {
	       	$window.scrollTop(0)
        	myPub.HamstopPropaga();
	    });

	    // 清空搜索框  oSearchClear
	    oSearchClear.hammer().on('tap',function() {
	        oSearchTxt.val('');
	        $(this).hide().siblings('.js_Text').val('').siblings('.js_error').hide().removeClass('on');
	    });

	    // 显示清空按钮
	    oSearchTxt.on('input propertychange',function() {
	        $(this).val() == '' ? oSearchClear.hide() : oSearchClear.show();
	    });
	    // 显示清空按钮(获取焦点)
	    oSearchTxt.on('focus',function() {
	        $(this).val() == '' ? oSearchClear.hide() : oSearchClear.show();
	    });

	    oSearchTxt.on('blur',function() {
	        $(this).val() == '' ? oSearchClear.hide() : oSearchClear.show();
	    });


	    // 限制字数
	    if(oUserMessage.length>0) {
	        myPub.statInputNum(oUserMessage,maxLWord);
	    }


	    //设置全部产品图片高度
	    var oHScroll = $('.js_HScroll');				//水平滚动 导航和产品
	  	var oGoods_showOne = $('.js_goods_showOne');	//一排产品


	  	myPub.SetImgHeight(oHScroll);
	  	myPub.SetImgHeight(oGoods_showOne);




		//页面滚动
		function WindowScroll() {
    		var scrollTime;
    		var _disY = $(window).scrollTop();

    		if(window.location.pathname.search('supplier/toSupplier') > 0) {
    			oSideBox.stop().animate({'right':0},250);
    		}
    		else {
    			_disY > 300 ? oSideBox.stop().animate({'right':0},250) : oSideBox.stop().animate({'right': '-3.5rem'},250);
    		}
    	}


	  	function LoadComplete(fn) {
			//当页面加载状态
			if(document.readyState == "complete") { if(fn)fn() }
			//console.log(document.readyState)
		}

  	})


	//购物车标记数量
	var oUserNum = $('.js_userNum');
	if(oUserNum.length > 0) {
		//购物车标记
	  	$.ajax({
			type: "POST",
			url: "/shop/cartItem/getCount",
			dataType: "json",
			success: function(data) {
				if(data.count != 0){
					oUserNum.html(data.count);
					oUserNum.show();
				}else{
					oUserNum.hide();
				}
			},
			error:function(textStatus){
				if(textStatus.status == 403){
					oUserNum.hide();
				}
			},
			complete:function(XHR) {
				XHR = null;
			}
		});
	}





});


